%option noyywrap
%option yylineno
%option never-interactive
%option noinput
%{

#include "command_utils.h"

// 添加以下两行以忽略未使用的函数警告
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic push

map<string, string> column_name_val;
string tmp;
bool name_flag = true;
%}
/*语法col_name1=col_value1,col_name2=col_value2,...*/
NAME_OR_VAL ['a-zA-Z0-9_.]+

%%
{NAME_OR_VAL} {if(name_flag){tmp=insert_table_text;name_flag = false;}else{column_name_val[tmp] = insert_table_text;name_flag = true;}}
[ \t\n]+    ;  /* 忽略空白 */
, ;//逗号
= ;//等于
. ; /* 忽略其他字符 */
<<EOF>>         { return 0; /* 确保 insert_table_lex 正常终止 */ }
%%
void init_flex_string(const char *str) {
    YY_BUFFER_STATE bp = insert_table__scan_string(str);
    if (!bp) {
        error("Failed to create buffer for input string.");
        return;
    }
    insert_table_lex(); // 开始扫描
    insert_table__delete_buffer(bp); // 删除缓冲区
}
map<string,string> insert_table_helper(string args) {
       init_flex_string(args.c_str());
       return column_name_val;
}

// 恢复原来的警告设置
#pragma GCC diagnostic pop
